package main

import (
	"encoding/xml"
	"fmt"
	"log"
)

// START OMIT
var feedXML = []byte(`<rss version="2.0">
  <channel>
    <item> <title>foo</title> <link>http://foo.com</link> </item>
  </channel>
</rss>`)

type Feed struct {
	Version string `xml:"version,attr"`
	Channel struct {
		Items []struct {
			Title string `xml:"title"`
			URL   string `xml:"link"`
		} `xml:"item"`
	} `xml:"channel"`
}

func main() {
	var feed Feed
	if err := xml.Unmarshal(feedXML, &feed); err != nil {
		log.Fatal("error parsing %q: %v", feedXML, err)
	}
	fmt.Println(feed.Version, feed.Channel.Items[0])
}

// STOP OMIT
